package com.example.goodtrash.search;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.goodtrash.R;

import java.util.List;

public class ViewPaperAdapter extends RecyclerView.Adapter<ViewPaperAdapter.ViewHolder> {
    private List<Integer> mlist;
    static class ViewHolder extends RecyclerView.ViewHolder{
      FrameLayout banner;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);banner=itemView.findViewById(R.id.banner);
        }
    }

    public ViewPaperAdapter (List<Integer> list){
        mlist=list;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item_view_banner,parent,false);
        ViewPaperAdapter.ViewHolder holder=new ViewPaperAdapter.ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        int i = position % 4;

        holder.banner.setBackgroundResource(mlist.get(i));
    }

    @Override
    public int getItemCount() {
        return  Integer.MAX_VALUE;
    }
}
